Repository navigation
Shared state + cache reuse: Postgres backend, adapter-aware caching, state inspection - #10
Merged
Merged
Conversation
This was referenced Sep 13, 2026
iamgp
force-pushed
the
feat/shared-state-cache
branch
from
September 14, 2026 08:29
96766f5 to
7797a52
Compare
iamgp
force-pushed
the
feat/shared-state-cache
branch
2 times, most recently
from
September 14, 2026 09:53
6c5938b to
d2c7733
Compare
iamgp
force-pushed
the
feat/shared-state-cache
branch
2 times, most recently
from
September 14, 2026 12:19
86d2e38 to
2668c66
Compare
…re caching, state inspection - PostgresStateStore: full StateStore impl behind a dedicated worker thread (the postgres client owns an internal Tokio runtime that cannot block inside the outer one); schema mirrors SQLite with upserts and an identity column for deterministic newest-first ordering. - --state / PHLO_STATE_URL: postgres:// selects the shared backend, any other value is a SQLite file path; explicit locations fail hard, never silently fall back, and credentials are redacted from errors/doctor. - Safe cross-environment cache reuse: a same-version record authorises Cached only when it names the same physical target AND was produced by the same adapter; otherwise Build with cache_miss. Current-env records from another adapter rebuild with adapter_change. Records persist the producing adapter (model_versions.adapter, best-effort migration). - phlo-transform state: runs / show <id|prefix> / model / promotions, human + --json. RunSummary gains environment. - Concurrency: SQLite busy_timeout(5s) so parallel processes on one state file wait out lock contention.
iamgp
force-pushed
the
feat/shared-state-cache
branch
from
September 14, 2026 13:25
2668c66 to
a22e5ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundle 6 — shared state + cache reuse.
PostgresStateStore— fullStateStoreimplementation mirroring the SQLite schema (upserts,BIGSERIALordering tiebreak, same migrations). Thepostgresclient drives an internal Tokio runtime that cannotblock_oninside the outer one, so the client lives on a dedicated worker thread and each trait call ships a closure over a channel — legal from sync and async callers alike.--state/PHLO_STATE_URL—postgres:///postgresql://selects the shared backend; any other value is a SQLite file path (default.phlo/transform/state.db). An explicitly configured location that fails is a hard error — never a silent fallback to local state — and credentials in the URL are stripped before it appears in errors ordoctoroutput.Cachedonly when it names the same physical target relation AND was produced by the same adapter; a same-version record failing either check yieldsbuildwith a newcache_missreason (detail names the mismatch), and a current-environment record produced by a different adapter rebuilds withadapter_change.model_versionsrecords the producingadapter(best-effortALTER TABLEmigration;NULLrows cannot authorise reuse).phlo-transform state— read-only inspection:runs(env filter),show <run-id|prefix>(model/seed/test records),model <name>(version components, target, adapter),promotions. All honour--json.RunSummarygainsenvironment.busy_timeout(5s)so parallel processes sharing a state file wait out lock contention.Test plan
cargo fmt --all -- --checkcleancargo clippy --workspace --all-targets -- -D warningscleancargo test --workspacegreen — incl. new:cache_reuse_requires_same_physical_target,cache_reuse_requires_same_adapter,cache_reuse_rejects_unrecorded_adapter,materialisation_by_another_adapter_rebuilds,concurrent_sqlite_writers_complete,state_commands_inspect_recorded_runs_on_duckdb,state_flag_selects_sqlite_path,unreachable_postgres_state_url_errorspostgres_roundtrip_run_and_versions(opt-in viaPHLO_TEST_POSTGRES_URL; skips cleanly without a server)